package com.liu.demo;


import com.liu.spring.framework.annotation.Autowired;
import com.liu.spring.framework.annotation.Component;
import com.liu.spring.framework.aware.BeanNameAware;
import com.liu.spring.framework.aware.InitializingBean;

/**
 * @author LIU
 * @version 1.0
 * @description: TODO
 * @date 2022/8/25 15:40
 */
//@Scope()
@Component("userService")
public class UserService implements UserInterface, InitializingBean, BeanNameAware {

    @Autowired
    private OrderService orderService;

    private String beanName;

    private String initValue;

    @Override
    public void test() {
        System.out.println("---执行实例逻辑---");
        System.out.println("注入对象:" + orderService);
    }

    @Override
    public void setBeanName(String beanName) {
        this.beanName = beanName;
        System.out.println("Aware回调机制 BeanName");
    }

    @Override
    public void afterPropertiesSet() {
        this.initValue = "初始化了";
        System.out.println("初始化方法");
    }

    @Override
    public String toString() {
        System.out.println("toString方法执行了");

        return "UserService{" +
                "beanName='" + beanName + '\'' +
                ", initValue='" + initValue + '\'' +
                '}';
    }
}
